extends EventListener


class_name Reward
"""
触发指定事件时掉落物品
"""


## 触发概率
@export var rate: RateAttribute = null
## 掉落的物品
@export var rewards: Array[InventoryItem] = []


# 处理消息
func on_message(e: CharacterEvent) -> void:
    if rewards.size() > 0 and rate.pick() == 0:
        return
    GameService.request_create_pickup.emit(rewards.pick_random().duplicate(), character.wrapper.global_position)
